<?php
namespace Application\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class IndexController extends AbstractActionController
{
    public $view;

    public function __construct(){
      $this->view = new ViewModel();
      $this->view->controller = 'index'; 
      $this->view->filePath = FILES_PATH;
    }

    public function indexAction(){
      $this->layout('layout/home');
      $productTable = $this->getServiceLocator()->get('Application\Model\ProductTable');
      $data = $productTable->fetchAll();
      $this->view->data = $data;
      return $this->view;
    }


    public function xemhangAction(){
      $this->layout('layout/home');
    	return $this->view;
    }

    public function chiTietAction(){
      $this->layout('layout/home');
      $id = $this->params()->fromRoute('id');
      $productTable = $this->getServiceLocator()->get('Application\Model\ProductTable');
      $data = $productTable->getProduct($id);
      $this->view->data = $data;
      
   		return $this->view;
    }

    public function lienheAction(){
      $this->layout('layout/home');
      return $this->view;
    }

    public function dathangAction(){
      $this->layout('layout/home');
      return $this->view;
    }
}